package com.wilmer.classTestDetails.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wilmer.common.annotation.Log;
import com.wilmer.common.core.controller.BaseController;
import com.wilmer.common.core.domain.AjaxResult;
import com.wilmer.common.enums.BusinessType;
import com.wilmer.classTestDetails.domain.YwClassTestsDetails;
import com.wilmer.classTestDetails.service.IYwClassTestsDetailsService;
import com.wilmer.common.utils.poi.ExcelUtil;
import com.wilmer.common.core.page.TableDataInfo;

/**
 * 随堂测试详情题 Controller
 * 
 * @author zl
 * @date 2024-04-11
 */
@RestController
@RequestMapping("/classTestDetails/classTestDetails")
public class YwClassTestsDetailsController extends BaseController
{
    @Autowired
    private IYwClassTestsDetailsService ywClassTestsDetailsService;

    /**
     * 查询随堂测试详情题 列表
     */
    @PreAuthorize("@ss.hasPermi('classTestDetails:classTestDetails:list')")
    @GetMapping("/list")
    public TableDataInfo list(YwClassTestsDetails ywClassTestsDetails)
    {
        startPage();
        List<YwClassTestsDetails> list = ywClassTestsDetailsService.selectYwClassTestsDetailsList(ywClassTestsDetails);
        return getDataTable(list);
    }

    /**
     * 导出随堂测试详情题 列表
     */
    @PreAuthorize("@ss.hasPermi('classTestDetails:classTestDetails:export')")
    @Log(title = "随堂测试详情题 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YwClassTestsDetails ywClassTestsDetails)
    {
        List<YwClassTestsDetails> list = ywClassTestsDetailsService.selectYwClassTestsDetailsList(ywClassTestsDetails);
        ExcelUtil<YwClassTestsDetails> util = new ExcelUtil<YwClassTestsDetails>(YwClassTestsDetails.class);
        util.exportExcel(response, list, "随堂测试详情题 数据");
    }

    /**
     * 获取随堂测试详情题 详细信息
     */
    @PreAuthorize("@ss.hasPermi('classTestDetails:classTestDetails:query')")
    @GetMapping(value = "/{testDetailId}")
    public AjaxResult getInfo(@PathVariable("testDetailId") Long testDetailId)
    {
        return success(ywClassTestsDetailsService.selectYwClassTestsDetailsByTestDetailId(testDetailId));
    }

    /**
     * 新增随堂测试详情题 
     */
    @PreAuthorize("@ss.hasPermi('classTestDetails:classTestDetails:add')")
    @Log(title = "随堂测试详情题 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YwClassTestsDetails ywClassTestsDetails)
    {
        return toAjax(ywClassTestsDetailsService.insertYwClassTestsDetails(ywClassTestsDetails));
    }

    /**
     * 修改随堂测试详情题 
     */
    @PreAuthorize("@ss.hasPermi('classTestDetails:classTestDetails:edit')")
    @Log(title = "随堂测试详情题 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YwClassTestsDetails ywClassTestsDetails)
    {
        return toAjax(ywClassTestsDetailsService.updateYwClassTestsDetails(ywClassTestsDetails));
    }

    /**
     * 删除随堂测试详情题 
     */
    @PreAuthorize("@ss.hasPermi('classTestDetails:classTestDetails:remove')")
    @Log(title = "随堂测试详情题 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{testDetailIds}")
    public AjaxResult remove(@PathVariable Long[] testDetailIds)
    {
        return toAjax(ywClassTestsDetailsService.deleteYwClassTestsDetailsByTestDetailIds(testDetailIds));
    }
}
